Skip to content

fix: Make the makeResolvable $internal marker writable - #2799

Merged
iwoplaza merged 1 commit into
mainfrom
fix/writable-internal
Aug 6, 2026
Merged

fix: Make the makeResolvable $internal marker writable#2799
iwoplaza merged 1 commit into
mainfrom
fix/writable-internal

Conversation

@reczkok

@reczkok reczkok commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Running current main on React Native crashes at module load with TypeError: Cannot assign to read-only property Symbol(typegpu:$internal) the moment anything creates a bind group layout.

makeResolvable marks class prototypes with Object.defineProperty(proto, $internal, { value: true }) - writable defaults to false. Classes like TgpuLaidOutBufferImpl declare the field and assign it in the constructor:

class TgpuLaidOutBufferImpl {
  readonly [$internal]: { readonly dataType: TData };
  constructor(...) {
    this[$internal] = { dataType };
  }
}

Whether that assignment survives depends on who compiles it. Vitest (oxc) keeps the field declaration as a native class field:

class TgpuLaidOutBufferImpl {
  [$internal];                        // defines an own writable property before the ctor body
  constructor(...) {
    this[$internal] = { dataType };   // writes to the own property, fine
  }
}

Babel (Metro) strips the uninitialized field entirely:

class TgpuLaidOutBufferImpl {
  constructor(...) {
    this[$internal] = { dataType };   // assignment walks the prototype chain,
  }                                   // finds the read-only marker, throws
}

Copilot AI review requested due to automatic review settings August 6, 2026 01:02
@reczkok reczkok changed the title fix: Make the makeResolvable $internal marker writable fix: Make the makeResolvable $internal marker writable Aug 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a React Native (Metro/Babel) module-load crash by ensuring the $internal symbol marker added by makeResolvable does not become a non-writable inherited property that blocks instance assignments.

Changes:

  • Marks the $internal symbol property as writable: true when defined via Object.defineProperty in makeResolvable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/eslint-plugin-typegpu@8c9ae93a20bf2bd02333b4f60ddf5edf246050b4
https://pkg.pr.new/software-mansion/TypeGPU/tgpu-gen@8c9ae93a20bf2bd02333b4f60ddf5edf246050b4
https://pkg.pr.new/software-mansion/TypeGPU/tinyest-for-wgsl@8c9ae93a20bf2bd02333b4f60ddf5edf246050b4
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@8c9ae93a20bf2bd02333b4f60ddf5edf246050b4
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@8c9ae93a20bf2bd02333b4f60ddf5edf246050b4
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/color@8c9ae93a20bf2bd02333b4f60ddf5edf246050b4
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@8c9ae93a20bf2bd02333b4f60ddf5edf246050b4
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@8c9ae93a20bf2bd02333b4f60ddf5edf246050b4
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/radiance-cascades@8c9ae93a20bf2bd02333b4f60ddf5edf246050b4
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/react@8c9ae93a20bf2bd02333b4f60ddf5edf246050b4
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/sdf@8c9ae93a20bf2bd02333b4f60ddf5edf246050b4
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/three@8c9ae93a20bf2bd02333b4f60ddf5edf246050b4
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@8c9ae93a20bf2bd02333b4f60ddf5edf246050b4

benchmark
view benchmark

commit
view commit

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • packages/typegpu/src/tgsl/makeResolvable.ts: added writable: true to the $internal marker descriptor so that class constructors can assign instance-specific $internal data without hitting a read-only prototype property on Babel/Metro (React Native) transpilations.

Pullfrog  | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Bundle size comparison (import * as ... in PR vs import * as ... in target):

🟢 Decreased ➖ Unchanged 🔴 Increased (max 0.00%) ❔ Unknown
0 301 21 0

import { ... } in PR vs import * as ... in PR (is the library tree-Shakeable?):

Test tsdown
tgpu_init.ts 260.45 kB ($${\color{green}-3.3\%}$$)
tgpu_initFromDevice.ts 259.92 kB ($${\color{green}-3.5\%}$$)
tgpu_resolve.ts 166.90 kB ($${\color{green}-38.0\%}$$)
tgpu_resolveWithContext.ts 166.83 kB ($${\color{green}-38.0\%}$$)
tgpu_bindGroupLayout.ts 71.53 kB ($${\color{green}-73.4\%}$$)
tgpu_mutableAccessor.ts 67.92 kB ($${\color{green}-74.8\%}$$)
tgpu_accessor.ts 67.92 kB ($${\color{green}-74.8\%}$$)
tgpu_privateVar.ts 66.66 kB ($${\color{green}-75.2\%}$$)
tgpu_workgroupVar.ts 66.66 kB ($${\color{green}-75.2\%}$$)
tgpu_const.ts 66.14 kB ($${\color{green}-75.4\%}$$)
tgpu_lazy.ts 66.02 kB ($${\color{green}-75.5\%}$$)
tgpu_fn.ts 38.45 kB ($${\color{green}-85.7\%}$$)
tgpu_fragmentFn.ts 38.45 kB ($${\color{green}-85.7\%}$$)
tgpu_vertexFn.ts 38.27 kB ($${\color{green}-85.8\%}$$)
tgpu_computeFn.ts 37.97 kB ($${\color{green}-85.9\%}$$)
tgpu_vertexLayout.ts 27.08 kB ($${\color{green}-89.9\%}$$)
tgpu_comptime.ts 14.77 kB ($${\color{green}-94.5\%}$$)
tgpu_unroll.ts 1.66 kB ($${\color{green}-99.4\%}$$)
tgpu_slot.ts 1.54 kB ($${\color{green}-99.4\%}$$)

If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Resolution Time Benchmark

---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.96, 1.97, 4.01, 6.75, 8.01, 12.90, 22.95, 25.11]
  line [1.02, 2.01, 3.89, 6.65, 7.85, 10.97, 21.32, 25.52]
  line [0.97, 2.02, 4.56, 6.88, 8.05, 11.84, 22.05, 24.59]
Loading
---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.33, 0.55, 0.72, 0.79, 1.08, 1.15, 1.36, 1.60]
  line [0.30, 0.50, 0.68, 0.79, 1.06, 1.17, 1.43, 1.55]
  line [0.28, 0.50, 0.70, 0.89, 1.15, 1.22, 1.46, 1.66]
Loading
---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.80, 2.05, 3.51, 7.22, 12.66, 25.19, 55.46, 110.73]
  line [0.78, 2.01, 3.87, 6.50, 11.92, 24.95, 56.08, 110.40]
  line [0.91, 2.24, 4.62, 6.31, 12.49, 25.96, 57.01, 113.44]
Loading

@iwoplaza
iwoplaza merged commit 70ea4c2 into main Aug 6, 2026
10 checks passed
@iwoplaza
iwoplaza deleted the fix/writable-internal branch August 6, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants